<html>
<body>
<script type="text/javascript" src="jnext/jnext.js"></script>
<script type="text/javascript" src="jnext/sockets.js"></script>
<script type="text/javascript" src="json.js"></script>
<script type="text/javascript" src="cache_memcached.js"></script>
<script type="text/javascript">
var myObject = new Array('aa','bb','cc');
var myJSONText = myObject.toJSONString();
var returnValue;

var mm = new CacheMemcached({
                                server: ['192.168.0.10',11211],
                                exptime: 3600,
                                flag: 0
                            });

function test_set() {
  var k = document.forms[0].set_key.value;
  var v = document.forms[0].set_value.value;
  mm.set(k,v,function(r){alert('set-response>' + r);} );
//  mm.add('hoge',v,function(r){alert('set-response>' + r);} );
//  mm.replace('hoge',v,function(r){alert('set-response>' + r);} );
// use JSON. set DataObject.
//  mm.set('hoge',myJSONText,function(r){alert('set-response>' + r);} );
}

function test_get() {
  var k = document.forms[0].get_key.value;
  mm.get(k,function(r){alert('get-response-value>' + r);});
// use JSON. get DataObject.
//  mm.get('hoge',function(r){returnValue=r.parseJSON();});
}

function test_close() {
  mm.close();
}

function test_flush_all() {
  mm.flush_all(function(f){alert('flush_all-response>' + f);});
}

function test_stats() {
  mm.stats( 
             function(s){ 
                           var str = "";
                           for(var i=0;i<s.length;i++){
                               str = str + s[i]+"<br/>";
                           }
                           document.getElementById('stats').innerHTML = str;
                        }
          );
}

function test_delete() {
  var k = document.forms[0].del_key.value;
  mm.remove(k,function(f){alert('delete-response>' + f);});
}

</script>
<h3>JNEXT memcached socket </h3>
<hr>
<form>
<p>
<input type=button value="Connect" onclick='test_connect()'><br>
<input type=button value="Close" onclick='test_close()'>
</p>
key:value<br/>
<input type="text" name="set_key" value="hoge" size="10">:<input type="text" name="set_value" value="foo" size="30"><input type=button value="Set" onclick='test_set()'><br/>
<p>
key:<input type="text" name="get_key" value="hoge" size="10"><input type=button value="Get" onclick='test_get()'>
</p>
<p>
key:<input type="text" name="del_key" value="hoge" size="10"><input type=button value="Delete" onclick='test_delete()'>
</p>
<input type=button value="FlushAll" onclick='test_flush_all()'>
<input type=button value="Stats" onclick='test_stats()'>
</p>
</form>
<div id="stats"></div>
<!--
please edit auth.txt.
----
MSIE C:\Program Files\Optimistec\JNEXT\ActiveX\jnext\auth.txt
Firefox c:\Program Files\Mozilla Firefox\plugins\jnext\auth.txt 

please add url and library.
----
file://           *
http://127.0.0.1  Sockets
http://example.com  Sockets
-->
</body>
</html>
